package com.chinadci.smartcommunitysystembackstage.controller;


import com.chinadci.smartcommunitysystembackstage.entity.ScsActivity;
import com.chinadci.smartcommunitysystembackstage.entity.ScsAdmin;
import com.chinadci.smartcommunitysystembackstage.service.ScsActivityService;
import com.chinadci.smartcommunitysystembackstage.service.ScsAdminService;
import com.chinadci.smartcommunitysystembackstage.util.DateTime;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Code Duck
 * @since 2021-04-13
 */
@CrossOrigin
@RestController
@Api("建业E家")
public class ScsActivityController {
    @Autowired
    private ScsActivityService service;

    //显示全部社区活动
    @ApiOperation(value = "显示全部社区活动")           //swagger
    @ApiImplicitParam(name = "type",value = "活动类型")       //表明要传入的参数
    @RequestMapping(value = "/api/sqhd",method = RequestMethod.GET)
    public Map Finds(String type){
        Map<String,Object> map=new HashMap<>();
        map.put("data",service.Find(type));
        return map;
    }

    //添加社区活动
    @ApiOperation(value = "添加社区活动")           //swagger
    @ApiImplicitParam(name = "ScsActivity",value = "对象")       //表明要传入的参数
    @RequestMapping(value = "/api/tjsq",method = RequestMethod.POST)
    public Map Insert(ScsActivity scs){
        Map<String,Object> map=new HashMap<>();
        scs.setACreateTime(DateTime.GetTime());
        map.put("admin",1);
        map.put("data",service.Insert(scs));
        return map;
    }

    //修改社区活动
    @ApiOperation(value = "修改社区活动")           //swagger
    @ApiImplicitParam(name = "ScsActivity",value = "对象")       //表明要传入的参数
    @RequestMapping(value = "/api/xgsq",method = RequestMethod.POST)
    public Map Update(ScsActivity scs){
        Map<String,Object> map=new HashMap<>();
        map.put("data",service.Update(scs));
        return map;
    }

    //删除社区活动
    @ApiOperation(value = "删除社区活动")           //swagger
    @ApiImplicitParam(name = "id",value = "社区活动编号")       //表明要传入的参数
    @RequestMapping(value = "/api/scsq",method = RequestMethod.POST)
    public Map Del(int id){
        Map<String,Object> map=new HashMap<>();
        map.put("data",service.Del(id));
        return map;
    }
    //查找id
    @ApiOperation(value = "查询社区活动id")           //swagger
    @ApiImplicitParam(name = "id",value = "社区活动编号")       //表明要传入的参数
    @RequestMapping(value = "/api/insert",method = RequestMethod.GET)
    public Map Insert(int id){
        Map<String,Object> map=new HashMap<>();
        map.put("data",service.Finds(id));
        return map;
    }
}
